package cn.jbolt.admin.monitor;

import cn.jbolt.core.api.JBoltApiBaseController;
import cn.jbolt.core.api.httpmethod.JBoltHttpGet;
import cn.jbolt.core.bean.JBoltDateRange;
import cn.jbolt.core.model.base.JBoltBaseModel;
import cn.jbolt.core.permission.CheckPermission;
import cn.jbolt.core.permission.UnCheckIfSystemAdmin;
import cn.jbolt.core.service.JBoltLoginLogService;
import cn.jbolt.core.service.base.JBoltBaseService;
import cn.jbolt.extend.permission.PermissionKey;
import com.jfinal.aop.Inject;
import com.jfinal.core.Path;
import com.jfinal.core.paragetter.Para;

/**
 * 登录日志controller
 * @ClassName:  LoginLogAdminController
 * @author: JFinal学院-小木 QQ：909854136
 * @date:   2020年5月12日
 */
@CheckPermission(PermissionKey.JBOLT_LOGIN_LOG)
@UnCheckIfSystemAdmin
@Path("/api/admin/loginLog")
public class LoginLogAdminController extends JBoltApiBaseController {
	@Inject
	private JBoltLoginLogService service;

	@Override
	protected JBoltBaseService<? extends JBoltBaseModel<?>> getModelService() {
		return service;
	}

	/**
	 * 查看详情
	 */
	@JBoltHttpGet
	public void index() {
		renderJBoltApiRet(findModelById());
	}

	@JBoltHttpGet
	public void datas(@Para(value = PAGE_PARAM_NAME,defaultValue = "1")Integer page,
					  @Para(value = PAGESIZE_PARAM_NAME,defaultValue = "15")Integer pageSize,
					  @Para(KEYWORDS_PARAM_NAME)String keywords,
					  @Para(DATE_RANGE_PARAM_NAME)JBoltDateRange dateRange
					  ){
		renderJBoltApiSuccessWithData(service.paginateAdminList(page,pageSize,keywords,dateRange));
	}
}
